﻿using Bettzueche.RLLibrary.Functions;
using Bettzueche.RLLibrary.Types;
using System;

namespace RLProject1.Model {
    /// <summary cref="IQValueFunction{S,A}">
    /// Wird (zur Zeit) nicht genutzt.
    /// </summary>
    class QValueFunction  : IStateValueFunction<GridState, GridAction> {
        /*
         * ACHTUNG! ADD-METHODEN NICHT IMPLEMENTIERT!
         */

        double[,] qVals;

        public QValueFunction(int numOfStates) {
            qVals = new double[numOfStates,8]; //magic number: 8 = Anzahl Aktionen (GridAction)
        }

        #region IStateValueFunction<GridState,GridAction> Members

        /// <summary cref="IQValueFunction{S,A}.this">
        /// </summary>
        public double this[GridState state, GridAction action] {
            get {
                return qVals[state.ID,(int)action.Direction];
            }
            set {
                qVals[state.ID, (int)action.Direction] = value;
            }
        }


        /// <summary>
        /// Not supported (yet)!
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public double[] GetEstimates(GridState state)
        {
            throw new NotImplementedException();
        }

        public void Add(IEligibilityFunction<GridAction, GridState> eFunction, double factor) {
            throw new NotImplementedException();
        }

        public void Add(IEligibilityFunction<GridAction, GridState> eFunction) {
            throw new NotImplementedException();
        }

        public void Add(Matrix m) {
            throw new NotImplementedException();
        }

        #endregion

        #region IStateValueFunction Members

        public double this[IState state, IAction action] {
            get {
                if (state is GridState) {
                    if (action is GridAction)
                        return this[(GridState)state, (GridAction)action];
                }
                throw new NotSupportedException("Implementation von state oder action nicht unterstützt.");
            }
            set {
                if (state is GridState) {
                    if (action is GridAction)
                        this[(GridState)state, (GridAction)action] = value;
                }
                throw new NotSupportedException("Implementation von state oder action nicht unterstützt.");
            }
        }

        public double[] GetEstimates(IState state) {
            if (state is GridState) {
                return this.GetEstimates((GridState)state);
            }
            throw new NotSupportedException("stet Impl nicht unterstützt");
        }

        #endregion


        
    }

}